#!/usr/bin/env python
# @FileName :01.test.py
# @Time :2024/4/8 15:39
# @Author :luobiao


def check_length(passwd):
    if len(passwd) < 8:
        return False, "长度小于8"
    return True, None

def check_passwd_cpl(passwd):
    low_passwd = any(ch.islower() for ch in passwd)
    upper_passwd = any(ch.isupper() for ch in passwd)
    digit_passwd = any(ch.isdigit() for ch in passwd)
    spl_passwd = any(not ch.isalnum for ch in passwd)
    tpye_passwd =sum([low_passwd + upper_passwd + digit_passwd + spl_passwd])
    if tpye_passwd < 3:
        return False, "密码没有由三种以上的字符组成"
    return  True, None

def check_passwd_rep(passwd):
    for i in range(len(passwd) - 2):
        if passwd[i:i+3] in passwd[i+3:] :
            return False, "有长度超过或等于3的字串"
    return True, None

def passwd_score(passwd):
    score = 2
    improve_passwd = []
    lenth, lenth_err = check_length(passwd)
    if lenth:
        score += 1
    else:
        improve_passwd.append(lenth_err)

    cpl, cpl_err = check_passwd_cpl(passwd)
    if cpl:
        score += 1
    else:
        improve_passwd.append(cpl_err)

    rep, rep_err = check_passwd_rep(passwd)
    if rep:
        score += 1
    else:
        improve_passwd.append(rep_err)

    return  score, improve_passwd


passwd = input("请输入密码：")
score, improve_passwd = passwd_score(passwd)
print(f"密码评分：{score}")
if improve_passwd:
    print(f"需要改进的是：{', '.join(improve_passwd)}")